﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data;
using PointOfSale.Global;
using PointOfSale.Class;

namespace PointOfSale.Report.Stock
{
	/// <summary>
	/// Summary description for frmDepartmentWiseStock.
	/// </summary>
	public class frmDepartmentWiseStock : System.Windows.Forms.Form
	{
		private CrystalDecisions.Windows.Forms.CrystalReportViewer crystalReportViewer1;
		private System.ComponentModel.Container components = null;
		private int departmentId;

		public frmDepartmentWiseStock( int di)
		{
			InitializeComponent();
			this.departmentId = di;
		}

		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.crystalReportViewer1 = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
			this.SuspendLayout();
			// 
			// crystalReportViewer1
			// 
			this.crystalReportViewer1.ActiveViewIndex = -1;
			this.crystalReportViewer1.DisplayGroupTree = false;
			this.crystalReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.crystalReportViewer1.Location = new System.Drawing.Point(0, 0);
			this.crystalReportViewer1.Name = "crystalReportViewer1";
			this.crystalReportViewer1.ReportSource = null;
			this.crystalReportViewer1.Size = new System.Drawing.Size(576, 333);
			this.crystalReportViewer1.TabIndex = 0;
			// 
			// frmDepartmentWiseStock
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(576, 333);
			this.Controls.Add(this.crystalReportViewer1);
			this.Name = "frmDepartmentWiseStock";
			this.Text = "Báo cáo lượng hàng trong kho";
			this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
			this.Load += new System.EventHandler(this.frmDepartmentWiseStock_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void frmDepartmentWiseStock_Load(object sender, System.EventArgs e)
		{
			dsWiseStock ds = new dsWiseStock();
			rptWiseStock rpt = new rptWiseStock();
			SqlCommand cmd = new SqlCommand("spWiseStock", clsGlobal.g_DataConn);
			cmd.CommandType = CommandType.StoredProcedure;
			cmd.Parameters.Add("@departmentId", System.Data.SqlDbType.NVarChar);
			cmd.Parameters["@departmentId"].Value = this.departmentId;
			SqlDataAdapter sda = new SqlDataAdapter(cmd);
			sda.Fill(ds, "spWiseStock");			
			
			string departmentName = clsDepartment.GetDepartmentName(this.departmentId);
			rpt.SetParameterValue("@DepartmentName", departmentName);
			rpt.SetDataSource(ds);
			this.crystalReportViewer1.ReportSource = rpt;
		}
	}
}

